﻿
<div class="page-container" id="admui-pageContent">
    <div class="page animation-fade page-forms">
        <div class="page-content">
            <div class="panel">
                <div class="page-header">
                    <h1 class="page-title">客户列表</h1>
                    <ol class="breadcrumb">
                        <li class="breadcrumb-item">
                            <a class="icon wb-home" href="javascript:;">客户管理</a>
                        </li>
                        <li class="breadcrumb-item active">客户列表</li>
                    </ol>
                </div>
                <div class="panel-body" style="padding-top:0px">
                    <h4 class="example-title">数据查询</h4>
                    <div class="row">
                        <div class="form-group col-sm-3" style="margin-bottom: 0px;">
                            <label class="col-form-label" for="for_XingBie">客户姓名</label>
                            <input id="ipt_KeHuXingMing" class="form-control" placeholder="请输入客户姓名" autocomplete="off" />
                        </div>
                        <div class="form-group col-sm-3 style=" margin-bottom: 0px;"">
                            <label class="col-form-label" for="for_XingBie">客户手机号</label>
                            <input id="ipt_KeHuShouJiHao" class="form-control" placeholder="请输入客户手机号" autocomplete="off" />
                        </div>
                        <div class="form-group col-sm-6 row" style="margin-bottom: 0px;">
                            <div class="form-group col-sm-6" style="padding-top: 0px; padding-right: 0px;margin-bottom: 0px;">
                                <label class="col-form-label" for="for_XingBie">从时间yyyy-MM-dd</label>
                                <input type="text" class="form-control empty" autocomplete="off" data-date-format="yyyy-mm-dd" name="" id="ipt_Kaishishijian" data-plugin="datepicker" data-language="zh-CN" placeholder="请选择开始时间" />
                            </div>
                            <div class="form-group col-sm-6" style="padding-top: 0px; padding-left: 0px;margin-bottom: 0px;">
                                <label class="col-form-label" for="for_XingBie">至时间yyyy-MM-dd</label>
                                <input type="text" class="form-control empty" autocomplete="off" data-date-format="yyyy-mm-dd" name="" id="ipt_JieShuShiJina" data-plugin="datepicker" data-language="zh-CN" placeholder="请选择结束时间" />
                            </div>
                            <div class="form-group col-sm-1"></div>
                        </div>
                        <div class="form-group col-sm-3">
                            <label class="col-form-label" for="for_XingBie">业务员</label>
                            <input id="ipt_YeWuYuanMingCheng" class="form-control" placeholder="请输入业务员姓名" autocomplete="off" />
                        </div>
                        <div class="form-group col-sm-3">
                            <label class="col-form-label" for="for_XingBie">置业顾问</label>
                            <input id="ipt_ZhYeGuWenMingCheng" class="form-control" placeholder="请输入置业顾问姓名" autocomplete="off" />
                        </div>
                        <div class="form-group col-sm-6 row">
                            <div class="form-group col-sm-6" style="padding-top:27px">
                                <button type="button" id="bt_ChaXun" class="btn btn-block btn-success" style="width: 95%; float: left;" onclick="bang()"><i class="icon wb-search"></i>查询</button>
                            </div>
                            <div class="form-group col-sm-6" style="padding-top:27px">
                                <button typeutton" id="bt_ChongZhi" class="btn btn-outline btn-success" style="width: 95%;" onclick="chongzhi();">重置</button>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="panel-body" style="margin-top:-50px">
                    <table class="table table-bordered table-hover dataTable table-striped w-full text-nowrap" id="dataTableExample" data-plugin="dataTable">
                        <thead>
                            <tr>
                                <th>姓名</th>
                                <th>业务员</th>
                                <th>置业顾问</th>
                                <th>手机号码</th>
                                <th>上次跟进时间</th>
                                <th>操作</th>
                            </tr>
                        </thead>
                        <tfoot>
                            <tr>
                                <th>姓名</th>
                                <th>业务员</th>
                                <th>置业顾问</th>
                                <th>手机号码</th>
                                <th>上次跟进时间</th>
                                <th>操作</th>
                            </tr>
                        </tfoot>
                        <tbody></tbody>
                    </table>
                </div>
            </div>
            <script type="text/javascript">
                $(document).ready(function () {
                    $("#SpanKeHu").click();
                    bang();
                });
                function bang() {
                    var lang = {
                        "sProcessing": "大量处理中，请稍后...",
                        "sLengthMenu": "每页 _MENU_ 项",
                        "sZeroRecords": "没有匹配结果",
                        "sInfo": "当前显示第 _START_ 至 _END_ 项，共 _TOTAL_ 项。",
                        "sInfoEmpty": "当前显示第 0 至 0 项，共 0 项",
                        "sInfoFiltered": "(由 _MAX_ 项结果过滤)",
                        "sInfoPostFix": "",
                        "sSearch": "搜索:",
                        "sUrl": "",
                        "sEmptyTable": "表中数据为空",
                        "sLoadingRecords": "载入中...",
                        "sInfoThousands": ",",
                        "oPaginate": {
                            "sFirst": "首页",
                            "sPrevious": "上页",
                            "sNext": "下页",
                            "sLast": "末页",
                            "sJump": "跳转"
                        },
                        "oAria": {
                            "sSortAscending": ": 以升序排列此列",
                            "sSortDescending": ": 以降序排列此列"
                        }
                    };
                    $("#dataTableExample").dataTable().fnDestroy();
                    $('#dataTableExample').dataTable({
                        "order": [[0, "asc"]],
                        "language": lang,
                        "processing": true,
                        "serverSide": true,
                        //"bStateSave": true,//状态保持模式
                        "searching": false,//禁用搜索
                        ajax: function (data, callback, settings) {
                            //封装请求参数
                            //console.log(data);
                            var param = {};
                            param.limit = data.length;//页面显示记录条数，在页面显示每页显示多少项的时候
                            param.start = data.start;//开始的记录序号
                            param.page = (data.start / data.length) + 1;//当前页码
                            param.dir = data.order[0].dir;
                            param.column = data.order[0].column;
                                 
                            param.ipt_KeHuXingMing = $("#ipt_KeHuXingMing").val();
                            param.ipt_KeHuShouJiHao = $("#ipt_KeHuShouJiHao").val();
                            param.ipt_Kaishishijian = $("#ipt_Kaishishijian").val();
                            param.ipt_JieShuShiJina = $("#ipt_JieShuShiJina").val();
                            param.ipt_YeWuYuanMingCheng = $("#ipt_YeWuYuanMingCheng").val();
                            param.ipt_ZhYeGuWenMingCheng = $("#ipt_ZhYeGuWenMingCheng").val();
                            //console.log(param);

                            //ajax请求数据
                            $.ajax({
                                type: "POST",
                                url: "../KeHu/InitializationDataTable",
                                cache: false,  //禁用缓存
                                data: param,  //传入组装的参数
                                dataType: "json",
                                success: function (result) {
                                    console.log(result);
                                    //setTimeout仅为测试延迟效果
                                    setTimeout(function () {
                                        //封装返回数据
                                        var returnData = {};
                                        returnData.draw = data.draw;//这里直接自行返回了draw计数器,应该由后台返回
                                        returnData.recordsTotal = result.total;//返回数据全部记录
                                        returnData.recordsFiltered = result.total;//后台不实现过滤功能，每次查询均视作全部结果
                                        returnData.data = result.data;//返回的数据列表
                                        //console.log(returnData);
                                        //调用DataTables提供的callback方法，代表数据已封装完成并传回DataTables进行渲染
                                        //此时的数据需确保正确无误，异常判断应在执行此回调前自行处理完毕"orderable" : false
                                        callback(returnData);
                                    }, 200);
                                }
                            });
                        },
                        //"columns": [
                        //    { "data": "KeHuXingMing" },
                        //    { "data": "t_XiaoShouBiaos[0].YeWuYuanId", render: function (data, type, row, meta) { if (row.t_XiaoShouBiaos != null && row.t_XiaoShouBiaos != "" && row.t_XiaoShouBiaos != undefined) { if (row.t_XiaoShouBiaos[0].YeWuYuanId != undefined && row.t_XiaoShouBiaos[0].YeWuYuanId != null && row.t_XiaoShouBiaos[0].YeWuYuanId != 0 ) { return row.t_XiaoShouBiaos[0].t_RenYuanBiao_YeWuYuan.XingMing; } else { return ""; } } else { return ""; } } },
                        //    { "data": "t_XiaoShouBiaos[0].ZhiYeGuWenId", render: function (data, type, row, meta) { if (row.t_XiaoShouBiaos != null && row.t_XiaoShouBiaos != "" && row.t_XiaoShouBiaos != undefined) { if (row.t_XiaoShouBiaos[0].ZhiYeGuWenId != undefined && row.t_XiaoShouBiaos[0].ZhiYeGuWenId != null && row.t_XiaoShouBiaos[0].ZhiYeGuWenId != 0 ) { return row.t_XiaoShouBiaos[0].t_RenYuanBiao_ZhiYeGuWen.XingMing; } else { return ""; } } else { return ""; } } },
                        //    { "data": "ShouJiHaoMa" },
                        //    { "data": "BeiZhu10" },
                        //    { "data": null }
                        //],
                        "columns": [
                            { "data": "xingming" },
                            { "data": "yewuyuanxingming" },
                            { "data": "zhiyeguwenxingming" },
                            { "data": "haoma" },
                            { "data": "shijian" },
                            { "data": null }
                        ],
                        columnDefs: [{
                            //   指定第最后一列
                            targets: -1,
                            //加下面属性 不参与排序
                            sortable: false,
                            render: function (data, type, row, meta) {
                                //alert(row.t_XiaoShouBiaos[0].t_RenYuanBiao_YeWuYuan.XingMing)
                                //alert(row.t_XiaoShouBiaos[0].t_RenYuanBiao_ZhiYeGuWen.XingMing)
                                return '<button type="button" class="btn btn-outline btn-default" onclick="XiuGai(' + row.Id + ')"><i class="icon wb-pencil" aria-hidden="true"></i>修改</button><button type="button" class="btn btn-outline btn-default" onclick="Detail(' + row.Id + ')"><i class="icon wb-pencil" aria-hidden="true"></i>查看详细</button>';
                            }
                        }]
                    });
                }
                function XiuGai(id) {
                    window.location.href = "../KeHu/KeHuAdd?Id=" + id;
                }
                function chongzhi() {
                    $("#ipt_KeHuXingMing").val("");
                    $("#ipt_KeHuShouJiHao").val("");
                    $("#ipt_Kaishishijian").val("");
                    $("#ipt_JieShuShiJina").val("");
                    $("#ipt_YeWuYuanMingCheng").val("");
                    $("#ipt_ZhYeGuWenMingCheng").val("");
                    //$("#inputSearch").val("");
                    bang();
                }
                function Detail(id) {
                    window.location.href = "../KeHu/Detail?Id=" + id;
                }
            </script>
        </div>
    </div>
</div>